* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow-y: auto;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
}

p {
  margin: 1rem auto;
  box-sizing: border-box;
}

.chat-container {
  max-width: 960px;
  margin: 2rem auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 1rem;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  border-radius: 12px 12px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h1 {
  font-size: 2rem;
  color: #212529;
}

.chat-header img {
  vertical-align: middle;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  position: relative;
}

ol,
ul {
  margin: 0.5rem 0;
  padding-left: 2rem;
}

ol li,
ul li {
  padding: 0.25rem 0;
  margin: 0;
}

ol li::marker {
  color: #666;
  font-weight: 500;
}

ul li::marker {
  color: #666;
}

ol li:last-child,
ul li:last-child {
  padding-bottom: 0;
}

ol li:first-child,
ul li:first-child {
  padding-top: 0;
}

.message {
  margin-bottom: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
  max-width: 80%;
  word-wrap: break-word;
}

.message.user {
  background: #e9ecef;
  margin-left: auto;
}

.message.assistant {
  background: #f8f9fa;
  margin-right: auto;
}

.message.system {
  background: #f8e3fa;
  margin-right: auto;
}

.message img {
  max-width: 100%;
  height: auto;
}

.chat-input-container {
  padding: 1rem;
  border-top: 1px solid #e9ecef;
  display: flex;
  gap: 0.5rem;
}

.chat-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 1rem;
  outline: none;
  resize: none;
  max-height: 200px;
  min-height: 50px;
  line-height: 1.5;
  font-family: inherit;
  overflow-y: auto;
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: #cbd5e1 transparent; /* Firefox */
}

.chat-input.drag-over {
  border-color: #0366d6;
  background-color: #f6f8fa;
}

/* Chrome, Edge, and Safari */
.chat-input::-webkit-scrollbar {
  width: 8px;
  background: transparent;
}

.chat-input::-webkit-scrollbar-track {
  background: transparent;
}

.chat-input::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Only show scrollbar when needed */
.chat-input::-webkit-scrollbar-thumb:vertical {
  min-height: 30px;
}

.chat-input:not(:hover)::-webkit-scrollbar-thumb {
  background-color: transparent;
}

.chat-input:focus {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.send-button {
  padding: 0.75rem 1.5rem;
  background: #0d6efd;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.2s;
}

.send-button:hover {
  background: #0b5ed7;
}

.send-button:disabled {
  background: #6c757d;
  cursor: not-allowed;
}

.stop-button {
  padding: 0.75rem 1.5rem;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.2s;
}

.stop-button:hover {
  background: #bb2d3b;
}

.stop-button:disabled {
  background: #6c757d;
  cursor: not-allowed;
}

.message pre {
  margin: 1rem auto;
  background: #fefefe;
  padding: 0.5rem;
  border-radius: 4px;
  overflow-x: auto;
  position: relative;
  white-space: pre-wrap;
}

.message blockquote {
  border-left: 4px solid #8b5cf6; /* Purple accent line */
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: rgba(139, 92, 246, 0.05); /* Very light purple background */
  border-radius: 0.375rem;
  font-style: italic;
  color: #4b5563; /* Slightly muted text */
}

/* Optional: Style nested blockquotes differently */
.message blockquote blockquote {
  border-left-color: #6d28d9; /* Darker purple for nested quotes */
  background: rgba(109, 40, 217, 0.05);
  margin-left: 1rem;
}

.copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
  z-index: 1;
}

.copy-button:hover {
  opacity: 1;
}

.copy-button svg {
  width: 16px;
  height: 16px;
  display: block;
}

.redo-button {
  padding: 0.5rem .5rem;
  background: #6c757d;
  color: white;
  padding: 8px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 20px;
  transition: color 0.2s;
}

.redo-button:hover {
  background: #5c636a;
}

.settings-button {
  padding: 0.5rem .5rem;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.2s;
}

.settings-button:hover {
  background: #5c636a;
}

.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-panel {
  background: white;
  padding: 20px;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.settings-header button {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

.setting-item {
  margin-bottom: 20px;
}

.setting-item label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
}

.setting-item input {
  width: 100%;
  margin-bottom: 8px;
}

.setting-description {
  font-size: 0.9em;
  color: #666;
  margin-top: 4px;
}

.setting-item.disabled label,
.setting-item.disabled input,
.setting-item.disabled .setting-description {
  opacity: 0.5;
  cursor: not-allowed;
}

.setting-item.disabled input {
  pointer-events: none;
}

.setting-item.disabled {
  pointer-events: none;
  opacity: 0.8;
}

.setting-item.disabled input[type="range"] {
  background: #ccc;
}

.setting-item.disabled label,
.setting-item.disabled .setting-description {
  color: #999;
}

/* Styling for penalty range inputs */
.penalty-range {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 8px;
}

/* Chrome track styling */
.penalty-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  border-radius: 8px;
  background: linear-gradient(to right,
    #ff000088 0%, 
    #00000022 30%,
    #00000022 70%,
    #ff000088 100%
  );
}

/* Firefox track styling */
.penalty-range::-moz-range-track {
  width: 100%;
  height: 6px;
  border-radius: 8px;
  background: linear-gradient(to right,
    #ff000088 0%, 
    #00000022 30%,
    #00000022 70%,
    #ff000088 100%
  );
}

/* Chrome thumb styling */
.penalty-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #666;
  cursor: pointer;
  margin-top: -5px; /* Centers the thumb on the track */
}

/* Firefox thumb styling */
.penalty-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: #666;
  cursor: pointer;
}

/* Completions Interface */
.completions-container {
  max-width: 960px;
  margin: 2rem auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 4rem);
}

.completions-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

#completions-input {
  flex: 1;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
}

.completions-controls {
  display: flex;
  gap: 0.5rem;
}

.complete-button {
  padding: 0.75rem 1.5rem;
  background: #0d6efd;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.2s;
}

.complete-button:hover {
  background: #0b5ed7;
}

.upload-button {
  padding: 0.5rem .5rem;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s;
}

.upload-button img {
  vertical-align: middle;
}

.upload-button:hover {
  background: #5c636a;
}

.mode-dropdown {
  display: none;
}

.mode-trigger {
  display: none;
}

.mode-menu {
  display: none;
}

.mode-item {
  display: none;
}

.mode-switch {
  display: none;
}

.menu-dropdown {
  position: relative;
  display: inline-block;
}

.menu-trigger {
  padding: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  color: #666;
  transition: color 0.2s;
}

.menu-trigger:hover {
  color: #000;
}

.menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 1000;
  min-width: 180px;
}

.menu.show {
  display: block;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.9rem;
  color: #333;
}

.menu-item:hover {
  background: #f8f9fa;
}

.menu-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f0f0f0;
  color: #666;
}

.menu-item.disabled:hover {
  background: #f0f0f0;
}

@media print {

  html,
  body {
    height: auto !important;
    overflow-y: visible;
  }

  .noprint {
    display: none;
  }

  .copy-button {
    display: none;
  }

  .chat-container {
    box-shadow: none;
    height: auto !important;
    max-width: none !important;
    overflow: visible !important;
  }

  .chat-header {
    border: none !important;
    page-break-inside: avoid;
  }

  .chat-messages {
    overflow-y: visible;
    border: none !important;
    height: auto !important;
    max-width: none !important;
  }

  .message {
    max-width: none !important;
  }

  .message.user {
    border: 1px solid #999;
  }
}

.prefill-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #eee;
}

.prefill-progress .progress-bar {
  height: 100%;
  background: #0d6efd;
  width: 0;
  transition: width 0.2s ease-out;
}

#prefill-status {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  gap: 10px;
}

.prefill-progress {
  flex: 1;
  height: 4px;
  background: #eee;
  border-radius: 2px;
  overflow: hidden;
}

.prefill-progress .progress-bar {
  height: 100%;
  background: #0d6efd;
  width: 0;
  transition: width 0.2s ease-out;
}

.ooc {
  vertical-align: middle;
  margin-left: 0.2rem;
}
